package com.hqyj.controller;

import com.hqyj.pojo.MakeApply;
import com.hqyj.pojo.Yan_liuyan;
import com.hqyj.service.service.InsertData;
import com.hqyj.service.service.LiuyanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;


@Controller
@RequestMapping("/customer")
public class customerApply {
    @Autowired
    InsertData insertData;

    @Autowired(required = false)
    LiuyanService liuyanService;
    // 处理用户申请服务 这里应该是有一个pojo类 用来接收传过来的json数据
    @RequestMapping("/apply")
    @ResponseBody
    public String apply(){
        return "申请成功";
    }

    @ResponseBody
    @RequestMapping("/liuyan")
    public String liuyan(Yan_liuyan yan_liuyan){
        String data = liuyanService.liuyan(yan_liuyan);
        if (data.equals("success")){
            return "留言成功";
        }
        return "留言失败";

    }


    @ResponseBody
    @RequestMapping("/serviceList")
    public List<MakeApply> service(String userName){
        List<MakeApply> lists = new ArrayList<>();
        lists = insertData.findByNameList(userName);
        return lists;
    }

}
